package co.fitstart.entity.site;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 区域
 * @author haiyan_xiao
 *
 */
@Entity
@Table(name="area")
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class Area {
    @Id
    @GeneratedValue
    private Long id;
    
    /** 城市等级，数值越低等级越高，高等级城市可以约低等级城市门店的课 */
    private Integer cityLevel;
    
    /** 区域等级，数值越低等级越高，高等级区域可以约低等级区域门店的课 */
    private Integer areaLevel;
    
    /** 区域名称 */
    private String name;
    
    /** 区域内门店 */
    @OneToMany(mappedBy = "area", fetch = FetchType.LAZY)
    @OrderBy("createTime ASC")
    @JSONField(serialize = false)
    private List<Site> sites;
    
    public Area() {
        
    }
    
    public Area(String name) {
        this.name = name;
        this.areaLevel = 0;
        this.cityLevel = 0;
    }
    
    /**
     * 
     * @param name
     * @return
     */
    public Area edit(String name) {
        this.name = name;
        
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the cityLevel
     */
    public Integer getCityLevel() {
        return cityLevel;
    }

    /**
     * @param cityLevel the cityLevel to set
     */
    public void setCityLevel(Integer cityLevel) {
        this.cityLevel = cityLevel;
    }

    /**
     * @return the areaLevel
     */
    public Integer getAreaLevel() {
        return areaLevel;
    }

    /**
     * @param areaLevel the areaLevel to set
     */
    public void setAreaLevel(Integer areaLevel) {
        this.areaLevel = areaLevel;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the sites
     */
    public List<Site> getSites() {
        return sites;
    }

    /**
     * @param sites the sites to set
     */
    public void setSites(List<Site> sites) {
        this.sites = sites;
    }
}
